//声明一个类接口，规定定义的类满足以下要求（name属性必传、age属性可选、sex属性只读，同时还拥有eat方法
class Students {
    public name:string;
    age?:number;
    readonly sex:string;
    constructor(names:string,age:number,sex:string){
        this.name=names
        this.age=age
        this.sex=sex
    }
}
function getClass(Myobj:Students ) {
    console.log(Myobj);
}
let Myobj = {
    name:'张三',
    age:25,
    sex:'男',
    address:'山西'
}
getClass(Myobj)


interface CLASSINTERFACE {
    name: string,
    age?: number,
    readonly sex: string
    eat?: () => {}
}
class ClassInterface {
    age: number
    constructor(age: number) {
        this.age = age
    }
    pop(obj: CLASS) {
        console.log(obj);
    }
}
let classInterface = new ClassInterface(18)
classInterface.pop({
    name: 'zhang',
    age: 18,
    sex: 'nv',
})
interface CLASSWORK {
    work?: () => {}
}
// 别名 重定义    & 交叉类型                                                                                                                                                                                                                                                                                                                                                                             
type CLASS = CLASSWORK & CLASSINTERFACE


